﻿<%@ Page Language="C#" MasterPageFile="~/castcom.master" AutoEventWireup="true" CodeFile="MemberEdit.aspx.cs"
    Inherits="MemberEdit" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:TextBox ID="tbTest" runat="server"></asp:TextBox>
    <table>
        <tr>
            <td>
                <table>
                    <tr>
                        <td>
                            Pseudo
                        </td>
                        <td>
                            &nbsp;
                            <asp:TextBox ID="tbPseudo" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Nom:
                        </td>
                        <td>
                            &nbsp;
                            <asp:TextBox ID="tbName" runat="server" EnableViewState="False"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvName" runat="server" 
                                ControlToValidate="tbName" ErrorMessage="*  Obligatoire"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Prenom:
                        </td>
                        <td>
                            &nbsp;
                            <asp:TextBox ID="tbPrename" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Date de naissance:
                        </td>
                        <td>
                            &nbsp;
                            <asp:TextBox ID="tbBirthDate" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Email:
                        </td>
                        <td>
                            &nbsp;
                            <asp:TextBox ID="tbMail" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Telephone:
                        </td>
                        <td>
                            &nbsp;
                            <asp:TextBox ID="tbPhoneNumber" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Radio:
                        </td>
                        <td>
                            &nbsp;
                            <asp:RadioButtonList ID="rbRadio" runat="server" RepeatDirection="Horizontal" TextAlign="Left">
                                <asp:ListItem Value="0">Non</asp:ListItem>
                                <asp:ListItem Value="1">Oui</asp:ListItem>
                            </asp:RadioButtonList>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Equipment:
                        </td>
                        <td>
                            &nbsp;
                            <asp:TextBox ID="tbEquipment" runat="server" Columns="32" Rows="7" TextMode="MultiLine"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Date d'engagement:
                        </td>
                        <td>
                            &nbsp;
                            <asp:TextBox ID="tbEngagementDate" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Fire Power:
                        </td>
                        <td>
                            &nbsp;
                            <asp:TextBox ID="tbFirePower" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Experience:
                        </td>
                        <td>
                            &nbsp;
                            <asp:TextBox ID="tbExperience" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                </table>
            </td>
            <td>
                <table>
                    <tr>
                        <td>
                            Grade:
                        </td>
                        <td>
                            &nbsp;
                            <asp:DropDownList ID="dlRank" runat="server">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Medaille:
                        </td>
                        <td>
                            &nbsp;
                            <asp:DropDownList ID="dlMedal" runat="server">
                            </asp:DropDownList>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    &nbsp;<asp:Button ID="bValid" runat="server" Text="Valider" OnClick="bValid_Click" />
    &nbsp;<asp:Button ID="bReset" runat="server" Text="Annuler" OnClick="bReset_Click" />
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="Matricule" 
        DataSourceID="SqlDataSource1" DefaultMode="Edit">
        <EditItemTemplate>
            Matricule:
            <asp:Label ID="MatriculeLabel1" runat="server" 
                Text='<%# Eval("Matricule") %>' />
            <br />
            Pseudo:
            <asp:TextBox ID="PseudoTextBox" runat="server" Text='<%# Bind("Pseudo") %>' />
            <br />
            Name:
            <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
            <br />
            Prename:
            <asp:TextBox ID="PrenameTextBox" runat="server" Text='<%# Bind("Prename") %>' />
            <br />
            BirthDate:
            <asp:TextBox ID="BirthDateTextBox" runat="server" 
                Text='<%# Bind("BirthDate") %>' />
            <br />
            Mail:
            <asp:TextBox ID="MailTextBox" runat="server" Text='<%# Bind("Mail") %>' />
            <br />
            PhoneNumber:
            <asp:TextBox ID="PhoneNumberTextBox" runat="server" 
                Text='<%# Bind("PhoneNumber") %>' />
            <br />
            Experience:
            <asp:TextBox ID="ExperienceTextBox" runat="server" 
                Text='<%# Bind("Experience") %>' />
            <br />
            Radio:
            <asp:TextBox ID="RadioTextBox" runat="server" Text='<%# Bind("Radio") %>' />
            <br />
            Equipment:
            <asp:TextBox ID="EquipmentTextBox" runat="server" 
                Text='<%# Bind("Equipment") %>' TextMode="MultiLine" />
            <br />
            FirePower:
            <asp:TextBox ID="FirePowerTextBox" runat="server" 
                Text='<%# Bind("FirePower") %>' />
            <br />
            EngagementDate:
            <asp:TextBox ID="EngagementDateTextBox" runat="server" 
                Text='<%# Bind("EngagementDate") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Update" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </EditItemTemplate>
        <InsertItemTemplate>
            Pseudo:
            <asp:TextBox ID="PseudoTextBox" runat="server" Text='<%# Bind("Pseudo") %>' />
            <br />
            Name:
            <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
            <br />
            Prename:
            <asp:TextBox ID="PrenameTextBox" runat="server" Text='<%# Bind("Prename") %>' />
            <br />
            BirthDate:
            <asp:TextBox ID="BirthDateTextBox" runat="server" 
                Text='<%# Bind("BirthDate") %>' />
            <br />
            Mail:
            <asp:TextBox ID="MailTextBox" runat="server" Text='<%# Bind("Mail") %>' />
            <br />
            PhoneNumber:
            <asp:TextBox ID="PhoneNumberTextBox" runat="server" 
                Text='<%# Bind("PhoneNumber") %>' />
            <br />
            Experience:
            <asp:TextBox ID="ExperienceTextBox" runat="server" 
                Text='<%# Bind("Experience") %>' />
            <br />
            Radio:
            <asp:TextBox ID="RadioTextBox" runat="server" Text='<%# Bind("Radio") %>' />
            <br />
            Equipment:
            <asp:TextBox ID="EquipmentTextBox" runat="server" 
                Text='<%# Bind("Equipment") %>' />
            <br />
            FirePower:
            <asp:TextBox ID="FirePowerTextBox" runat="server" 
                Text='<%# Bind("FirePower") %>' />
            <br />
            EngagementDate:
            <asp:TextBox ID="EngagementDateTextBox" runat="server" 
                Text='<%# Bind("EngagementDate") %>' />
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insert" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </InsertItemTemplate>
        <ItemTemplate>
            Matricule:
            <asp:Label ID="MatriculeLabel" runat="server" Text='<%# Eval("Matricule") %>' />
            <br />
            Pseudo:
            <asp:Label ID="PseudoLabel" runat="server" Text='<%# Bind("Pseudo") %>' />
            <br />
            Name:
            <asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
            <br />
            Prename:
            <asp:Label ID="PrenameLabel" runat="server" Text='<%# Bind("Prename") %>' />
            <br />
            BirthDate:
            <asp:Label ID="BirthDateLabel" runat="server" Text='<%# Bind("BirthDate") %>' />
            <br />
            Mail:
            <asp:Label ID="MailLabel" runat="server" Text='<%# Bind("Mail") %>' />
            <br />
            PhoneNumber:
            <asp:Label ID="PhoneNumberLabel" runat="server" 
                Text='<%# Bind("PhoneNumber") %>' />
            <br />
            Experience:
            <asp:Label ID="ExperienceLabel" runat="server" 
                Text='<%# Bind("Experience") %>' />
            <br />
            Radio:
            <asp:Label ID="RadioLabel" runat="server" Text='<%# Bind("Radio") %>' />
            <br />
            Equipment:
            <asp:Label ID="EquipmentLabel" runat="server" Text='<%# Bind("Equipment") %>' />
            <br />
            FirePower:
            <asp:Label ID="FirePowerLabel" runat="server" Text='<%# Bind("FirePower") %>' />
            <br />
            EngagementDate:
            <asp:Label ID="EngagementDateLabel" runat="server" 
                Text='<%# Bind("EngagementDate") %>' />
            <br />
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                CommandName="Edit" Text="Edit" />
&nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                CommandName="Delete" Text="Delete" />
            &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="New" />
        </ItemTemplate>
    </asp:FormView>
    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConflictDetection="CompareAllValues" 
        ConnectionString="Data Source=LEVASSEUR\SQLEXPRESS;Initial Catalog=DBCASTCOM;Integrated Security=True" 
        DeleteCommand="DELETE FROM [User] WHERE [Matricule] = @original_Matricule AND [Pseudo] = @original_Pseudo AND [Name] = @original_Name AND [Prename] = @original_Prename AND [BirthDate] = @original_BirthDate AND [Mail] = @original_Mail AND [PhoneNumber] = @original_PhoneNumber AND [Experience] = @original_Experience AND [Radio] = @original_Radio AND [Equipment] = @original_Equipment AND [FirePower] = @original_FirePower AND [EngagementDate] = @original_EngagementDate" 
        InsertCommand="INSERT INTO [User] ([Pseudo], [Name], [Prename], [BirthDate], [Mail], [PhoneNumber], [Experience], [Radio], [Equipment], [FirePower], [EngagementDate]) VALUES (@Pseudo, @Name, @Prename, @BirthDate, @Mail, @PhoneNumber, @Experience, @Radio, @Equipment, @FirePower, @EngagementDate)" 
        OldValuesParameterFormatString="original_{0}" 
        ProviderName="System.Data.SqlClient" 
        SelectCommand="SELECT [Matricule], [Pseudo], [Name], [Prename], [BirthDate], [Mail], [PhoneNumber], [Experience], [Radio], [Equipment], [FirePower], [EngagementDate] FROM [User] WHERE ([Matricule] = @Matricule)" 
        UpdateCommand="UPDATE [User] SET [Pseudo] = @Pseudo, [Name] = @Name, [Prename] = @Prename, [BirthDate] = @BirthDate, [Mail] = @Mail, [PhoneNumber] = @PhoneNumber, [Experience] = @Experience, [Radio] = @Radio, [Equipment] = @Equipment, [FirePower] = @FirePower, [EngagementDate] = @EngagementDate WHERE [Matricule] = @original_Matricule AND [Pseudo] = @original_Pseudo AND [Name] = @original_Name AND [Prename] = @original_Prename AND [BirthDate] = @original_BirthDate AND [Mail] = @original_Mail AND [PhoneNumber] = @original_PhoneNumber AND [Experience] = @original_Experience AND [Radio] = @original_Radio AND [Equipment] = @original_Equipment AND [FirePower] = @original_FirePower AND [EngagementDate] = @original_EngagementDate">
        <SelectParameters>
            <asp:QueryStringParameter DefaultValue="0" Name="Matricule" 
                QueryStringField="UserId" Type="Int32" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="original_Matricule" Type="Int32" />
            <asp:Parameter Name="original_Pseudo" Type="String" />
            <asp:Parameter Name="original_Name" Type="String" />
            <asp:Parameter Name="original_Prename" Type="String" />
            <asp:Parameter Name="original_BirthDate" Type="DateTime" />
            <asp:Parameter Name="original_Mail" Type="String" />
            <asp:Parameter Name="original_PhoneNumber" Type="String" />
            <asp:Parameter Name="original_Experience" Type="Int32" />
            <asp:Parameter Name="original_Radio" Type="Int32" />
            <asp:Parameter Name="original_Equipment" Type="String" />
            <asp:Parameter Name="original_FirePower" Type="Int32" />
            <asp:Parameter Name="original_EngagementDate" Type="DateTime" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Pseudo" Type="String" />
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Prename" Type="String" />
            <asp:Parameter Name="BirthDate" Type="DateTime" />
            <asp:Parameter Name="Mail" Type="String" />
            <asp:Parameter Name="PhoneNumber" Type="String" />
            <asp:Parameter Name="Experience" Type="Int32" />
            <asp:Parameter Name="Radio" Type="Int32" />
            <asp:Parameter Name="Equipment" Type="String" />
            <asp:Parameter Name="FirePower" Type="Int32" />
            <asp:Parameter Name="EngagementDate" Type="DateTime" />
            <asp:Parameter Name="original_Matricule" Type="Int32" />
            <asp:Parameter Name="original_Pseudo" Type="String" />
            <asp:Parameter Name="original_Name" Type="String" />
            <asp:Parameter Name="original_Prename" Type="String" />
            <asp:Parameter Name="original_BirthDate" Type="DateTime" />
            <asp:Parameter Name="original_Mail" Type="String" />
            <asp:Parameter Name="original_PhoneNumber" Type="String" />
            <asp:Parameter Name="original_Experience" Type="Int32" />
            <asp:Parameter Name="original_Radio" Type="Int32" />
            <asp:Parameter Name="original_Equipment" Type="String" />
            <asp:Parameter Name="original_FirePower" Type="Int32" />
            <asp:Parameter Name="original_EngagementDate" Type="DateTime" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Pseudo" Type="String" />
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Prename" Type="String" />
            <asp:Parameter Name="BirthDate" Type="DateTime" />
            <asp:Parameter Name="Mail" Type="String" />
            <asp:Parameter Name="PhoneNumber" Type="String" />
            <asp:Parameter Name="Experience" Type="Int32" />
            <asp:Parameter Name="Radio" Type="Int32" />
            <asp:Parameter Name="Equipment" Type="String" />
            <asp:Parameter Name="FirePower" Type="Int32" />
            <asp:Parameter Name="EngagementDate" Type="DateTime" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
        ContextTypeName="CCOMDataAccess.DataClassesDataContext" EnableUpdate="True" 
        Select="new (Pseudo, Name, Prename, BirthDate, Mail, PhoneNumber, Experience, Radio, Equipment, FirePower, EngagementDate, Matricule)" 
        TableName="Users" Where="Matricule == @Matricule">
        <WhereParameters>
            <asp:QueryStringParameter DefaultValue="0" Name="Matricule" 
                QueryStringField="UserId" Type="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>
    
</asp:Content>
